package com.ruoyi.web.controller.gxs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gxs.domain.GxsSubtype;
import com.ruoyi.gxs.service.IGxsSubtypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 扣分子类型Controller
 * 
 * @author 高晓松
 * @date 2023-12-27
 */
@RestController
@RequestMapping("/gxs/subtype")
public class GxsSubtypeController extends BaseController
{
    @Autowired
    private IGxsSubtypeService gxsSubtypeService;

    /**
     * 查询扣分子类型列表
     */
//    @PreAuthorize("@ss.hasPermi('gxs:subtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(GxsSubtype gxsSubtype)
    {
        startPage();
        List<GxsSubtype> list = gxsSubtypeService.selectGxsSubtypeList(gxsSubtype);
        return getDataTable(list);
    }

    /**
     * 导出扣分子类型列表
     */
//    @PreAuthorize("@ss.hasPermi('gxs:subtype:export')")
    @Log(title = "扣分子类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GxsSubtype gxsSubtype)
    {
        List<GxsSubtype> list = gxsSubtypeService.selectGxsSubtypeList(gxsSubtype);
        ExcelUtil<GxsSubtype> util = new ExcelUtil<GxsSubtype>(GxsSubtype.class);
        util.exportExcel(response, list, "扣分子类型数据");
    }

    /**
     * 获取扣分子类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('gxs:subtype:query')")
    @GetMapping(value = "/{gxsSubtypeId}")
    public AjaxResult getInfo(@PathVariable("gxsSubtypeId") Long gxsSubtypeId)
    {
        return success(gxsSubtypeService.selectGxsSubtypeByGxsSubtypeId(gxsSubtypeId));
    }

    /**
     * 新增扣分子类型
     */
//    @PreAuthorize("@ss.hasPermi('gxs:subtype:add')")
    @Log(title = "扣分子类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GxsSubtype gxsSubtype)
    {
        return toAjax(gxsSubtypeService.insertGxsSubtype(gxsSubtype));
    }

    /**
     * 修改扣分子类型
     */
//    @PreAuthorize("@ss.hasPermi('gxs:subtype:edit')")
    @Log(title = "扣分子类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GxsSubtype gxsSubtype)
    {
        return toAjax(gxsSubtypeService.updateGxsSubtype(gxsSubtype));
    }

    /**
     * 删除扣分子类型
     */
//    @PreAuthorize("@ss.hasPermi('gxs:subtype:remove')")
    @Log(title = "扣分子类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gxsSubtypeIds}")
    public AjaxResult remove(@PathVariable Long[] gxsSubtypeIds)
    {
        return toAjax(gxsSubtypeService.deleteGxsSubtypeByGxsSubtypeIds(gxsSubtypeIds));
    }
}
